﻿using System;
#region 参考文献

//主文献  ：https://blog.csdn.net/xinyalong/article/details/91563731?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522164126344316780265439795%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=164126344316780265439795&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~baidu_landing_v2~default-1-91563731.first_rank_v2_pc_rank_v29&utm_term=log4net.ILog&spm=1018.2226.3001.4187
//辅助1：https://www.cnblogs.com/anderslly/archive/2007/03/09/log4netconfigsamples.html
//辅助2：https://www.cnblogs.com/kpijixi/articles/7250796.html
//辅助3：https://blog.csdn.net/weixin_33890499/article/details/90128478
//辅助4：https://developer.aliyun.com/article/367107

#endregion
[assembly: log4net.Config.XmlConfigurator(Watch = true)]//别忘了在AssemblyInfo.cs文件中加入这一行，不然就会打印不了日志信息的。
namespace log
{
    class Program
    {

        static void Main(string[] args)
        {
            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);//否者无法启动控制台日志，无法启动颜色
            Console.WriteLine("Hello World!");

            try
            {
                Connection connection = new Connection();
                if (connection.Id==null)
                {
                    LogHelper.Debug(typeof(Connection), "111111");
                    LogHelper.Info(typeof(Connection), "222222");
                    LogHelper.Warn(typeof(Connection), "333333");
                    LogHelper.Error(typeof(Connection), "444444");
                    LogHelper.Fatal(typeof(Connection), "555555");


                   throw new ArgumentNullException("抛出异常");
                    
                }
              
            }
            catch (Exception ex)
            {
                LogHelper.Debug(typeof(Connection), ex);
                LogHelper.Warn(typeof(Connection), ex);
                LogHelper.Error(typeof(Connection), ex);
                LogHelper.Fatal(typeof(Connection), ex);

            }
           
        }
    }

    public class Connection
    {
        public string Id { get; set; }
    }
}
